package org.java.date;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 * Created by Administrator on 2016/11/14.
 */
public class DateTest {

    public static void main(String[] args) throws ParseException {
        // 测试日期格式化
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar c = Calendar.getInstance();
        //c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH));
        System.out.println(sdf.format(c.getTime()));
        System.out.println(sdf.format(System.currentTimeMillis()));

        // java.sql.Date 格式化
        java.util.Date util_date = c.getTime();
        java.sql.Date sql_date = new java.sql.Date(util_date.getTime());
        System.out.println(util_date);
        System.out.println(sql_date);

    }
}
